﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using DependencyInjection;

using StandardLibrary;
using StandardLibraryXNA;
using StandardFramework;

using PolarExpress.Model.Interfaces;
using PolarExpress.View.Interfaces;
using PolarExpress.Controller.Interfaces;

namespace PolarExpress.Controller
{
    public class SceneController : ISceneController
    {
        ISceneView _view;

        IProject _project;
        
        [Inject]
        public SceneController(IProject project, ISceneView view)
        {
            _project = project;
            _view = view;

            _view.ComponentDragDrop += new PluginHandler(_view_ComponentDragDrop);
        }

        void _view_ComponentDragDrop(PluginEventArgs args)
        {   
            BaseComponent component = (BaseComponent)Activator.CreateInstance(args.Plugin.Type);

            BoundComponentData bound = new BoundComponentData(new System.Drawing.Rectangle(args.X,args.Y,100,50));
            BoundComponentXNAData boundXNA = new BoundComponentXNAData(bound);

            component.AddComponent(bound);
            component.AddComponent(boundXNA);

            _project.Add(component);
        }

        public Model.Interfaces.IModel Model
        {
            get
            {
                return _project;
            }
            set
            {
                if (value is IProject)
                {
                    _project = (IProject)value;
                }
            }
        }

        public View.Interfaces.IView View
        {
            get
            {
                return _view;
            }
            set
            {
                if (value is ISceneView)
                {
                    _view = (ISceneView)value;
                }
            }
        }

        
    }
}
